<!DOCTYPE html>
<html>

	<head>
		<title></title>
		<meta charset="UTF-8" />
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
		<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=G3KsOmqT7ruGRgxmU9dtpb4r8kjSlMiy"></script>
		<script type="text/javascript" src="http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script>
		<script type="text/javascript" src="http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script>
		<style type="text/css">
			html {
				height: 100%
			}
			
			body {
				height: 100%;
				margin: 0px;
				padding: 0px
			}
			
			#container {
				height: 100%
			}
		</style>
	</head>

	<body>
		<div id="container"></div>
		<script type="text/javascript">
			var map = new BMap.Map("container");
			var point = new BMap.Point(116.404, 39.915);

			var markers = [];

			var marker = new BMap.Marker(point); // 创建标注 

			map.addOverlay(marker);
			//			addToMarkers(marker);
			map.centerAndZoom(point, 11);
			var local = new BMap.LocalSearch(map, {
				renderOptions: {
					map: map
				}
			});
			local.search("景点");
			map.enableScrollWheelZoom(true);

			function addToMarkers(marker) {
				markers.push(marker);
				//最简单的用法，生成一个marker数组，然后调用markerClusterer类即可。
				var markerClusterer = new BMapLib.MarkerClusterer(map, {
					markers: markers
				});
			};

			//单击获取点击的经纬度
			map.addEventListener("click", function(e) {
				var newPoint = new BMap.Point(e.point.lng, e.point.lat);
				var marker = new BMap.Marker(newPoint); // 创建标注 
				addToMarkers(marker);
				map.addOverlay(marker);
				var myGeo = new BMap.Geocoder();
				myGeo.getLocation(newPoint, function(rs) {
					var addComp = rs.addressComponents;
					var address = addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber;
					var opts = {
						width: 120, // 信息窗口宽度    
						height: 60, // 信息窗口高度    
						title: address // 信息窗口标题   
					}
					var infoWindow = new BMap.InfoWindow(e.point.lng + "," + e.point.lat, opts); // 创建信息窗口对象    
					map.openInfoWindow(infoWindow, newPoint); // 打开信息窗口
				});

			});
		</script>
	</body>

</html>